import requests


# json传参: text传递为空
def test_submit_api_01():
    resp = requests.post(
        "http://127.0.0.1:8000/example/submit",
        json={"quality": 5, "attitude": 5, "speed": 5, "text": "", "annoy": True},
    )

    assert "Django 站点管理员" in resp.text


# json传参: text传递不为空
def test_submit_api_02():
    resp = requests.post(
        "http://127.0.0.1:8000/example/submit",
        json={"quality": 5, "attitude": 5, "speed": 5, "text": "123", "annoy": True},
    )

    assert "Django 站点管理员" in resp.text
    # print(resp.json(), type(resp.json()))


# data传参:text传递为不为空
def test_submit_api_03():
    resp = requests.post(
        "http://127.0.0.1:8000/example/submit",
        data={"quality": 5, "attitude": 5, "speed": 5, "text": "123", "annoy": True},
    )

    assert "Django 站点管理员" in resp.text


# data传参:text传递为为空
def test_submit_api_04():
    resp = requests.post(
        "http://127.0.0.1:8000/example/submit",
        data={"quality": 5, "attitude": 5, "speed": 5, "text": "", "annoy": True},
    )
    # print(resp.text)
    assert "Django 站点管理员" in resp.text


# get方法
def test_submit_api_05():
    resp = requests.get(
        "http://127.0.0.1:8000/example/submit",
    )

    assert "Django 站点管理员" in resp.text
